package com.baizhi;

import com.alibaba.druid.pool.DruidDataSource;
import com.baizhi.entity.CmfzMenu;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;

/**
 * @SpringBootApplication 组合注解
 * @ComponentScan 组件扫描
 * @EnableAutoConfiguration  开启自动配置
 * @Configuration 配置类 相当于xml文件 声明当前类为配置类  类中环境可以认为是工厂环境
 * 配置 @Bean 可以创建对象
 */
@SpringBootApplication
@MapperScan("com.baizhi.dao")
public class  CmfzdemoApplication {
    
    public static void main(String[] args) {
        SpringApplication.run(CmfzdemoApplication.class, args);
    }

    /**
     * @Bean 相当于bean标签  创建的对象通过返回值返回  会交给工厂来管理
     *
     * @return
     */
    @Bean
    public DruidDataSource druidDataSource(){
        DruidDataSource druidDataSource = new DruidDataSource();
        druidDataSource.setDriverClassName("com.mysql.jdbc.Driver");
        druidDataSource.setUrl("jdbc:mysql://localhost:3306/cmfz?useUnicode=true&characterEncoding=utf8");
        druidDataSource.setUsername("root");
        druidDataSource.setPassword("hr");
        return druidDataSource;
    }
}
